# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_Adminsite_session_id'
   public
  def current_user
    @current_user ||= session[:user_id] ? User.find_by_id(session[:user_id]) : nil
  end  
  include LoginSystem
  private
  
  def authorize

    unless User.find_by_id(session[:user_id])
      flash[:notice] = "Please log in,Note that you need to register first if have not registered yet!"
      redirect_to(:controller => "account", :action => "login")
      #return false
    end
  end    
end
